home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Day Cry
/
Day Cry CD.bin
/
oh_towns
/
ein
/
sources
/
einlib.lzh
/
LIBSRC.LZH
/
EIN_FL06.C
< prev
next >
Wrap
C/C++ Source or Header
|
1994-07-18
|
3KB
|
108 lines
/*<Header>==============================================================
*
* FILE MANAGER / "EIN_FL06.C"
*
* [ EIN(tm) project : âtâ@âCâïæÇì∞òΓÅòè╓ÉöîQ ]
*
* COPYRIGHT Nam 1994, All rights reserved.
*
*-----------------------------------------------------------------------
* V1.0L01â┐ 94.07.07/Nam âvâìâgâ^âCâv
*</Header>==============================================================*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <snd.h>
#include <winb.h>
#include <te.h>
#include <fntb.h>
#include <gui.h>
#define EIN_FILE
#include "..\eintm.h"
#ifndef NOERR
#define NOERR (0)
#endif
#ifndef ERROR
#define ERROR (1)
#endif
extern FILE *EIN_fopen();
extern int EIN_remove();
/*<Func>================================================================
* int EIN_makeBackupFile( char *fullpath, char *ext )
*
* üyèT ùvüz âtâ@âCâïé╠âoâbâNâAâbâvé≡ì∞ɼé╡é▄é╖
*
* üyï@ ö\üz
* int24hânâôâhâëé≡âtâbâNé╡é─éóéΘé╠é┼üAâhâëâCâué╔âAâNâZâX
* é┼é½é╚é⌐é┴é╜ÅΩìçé┼éαâVâFâïé╠âAâëü[âgé≡Åoé╡é▄é╣é±üB
*
* üyôⁿ ù═üz
* *fullpath : ìφÅ£é╖éΘâtâ@âCâïû╝ò╢ÄÜù±é╓é╠â|âCâôâ^
* *ext : âoâbâNâAâbâvâtâ@âCâïé╠ègÆúÄq(NULLé╚éτ"BAK")
* [ùß] EIN_makeBackupFile("a:\\tmp.c", NULL);
* EIN_makeBackupFile("a:\\tmp.h", "OLD");
*
* üyÅo ù═üz
*
* üyè╓ÉöÆlüz != NULL É│ÅφÅIù╣(âtâ@âCâïâ|âCâôâ^)
* == NULL ê┘ÅφÅIù╣
*
* üyÆì ê╙üz
*
* üyÄQ Å╞üz
*
*-----------------------------------------------------------------------
* V11L10 1994.07.16/Nam
*</Func>==============================================================*/
int EIN_makeBackupFile( char *fullpath, char *extname )
{
FILE *fp;
char backpath[128], ext[8];
if ( fullpath == NULL ){
return ERROR;
}
if ( extname != NULL ){
strncpy( ext, extname, 4);
}
// âoâbâNâAâbâvâtâ@âCâïû╝é≡É▌ÆΦ
EIN_fnameNonExt( fullpath, backpath );
strcat( backpath, ".");
strcat( backpath, ext);
#ifdef DEBUG
printf("%s->%s\n", fullpath, backpath);
#endif
// âZü[âué╡é╜éóâtâ@âCâïû╝é¬æ╢ì▌é╡é╚éóé╚éτë╜éαé╣é╕ÅIù╣
fp = EIN_fopen( fullpath, "rb" );
if ( fp == NULL ){
return NOERR;
}
fclose( fp );
// î├éóâoâbâNâAâbâvâtâ@âCâïé¬éáéΩé╬ìφÅ£é╖éΘ
fp = EIN_fopen( backpath, "rb" );
if ( fp != NULL ){
fclose( fp );
if ( EIN_remove( backpath ) != 0 ){
#ifdef DEBUG
printf("\t: î├éóâoâbâNâAâbâvâtâ@âCâïé≡ìφÅ£é┼é½é▄é╣é±é┼é╡é╜.\n");
printf(" %s\n", backpath );
#endif
return ERROR;
}
}
// î╗ì▌é╠âtâ@âCâïé≡âoâbâNâAâbâvû╝é╔âèâlü[âÇé╖éΘ
if ( rename( fullpath, backpath ) != 0 ){
#ifdef DEBUG
printf("\t: âoâbâNâAâbâvâtâ@âCâïé≡ì∞ɼé┼é½é▄é╣é±é┼é╡é╜.\n");
printf(" %s->%s\n", fullpath, backpath );
#endif
return ERROR;
}
return NOERR;
}